package cn.snowtech.bluebox.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class DateUtil {

    private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static String formatshtDateTime(Date date) {

        return dateFormat.format(date);

    }

    public static String getCurrentDate() {
        return dateFormat.format(new Date());
    }

    public static String getDateOfNextYear() {
        Calendar calendar = Calendar.getInstance();
        Date date = new Date(System.currentTimeMillis());
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, 1);
        date = calendar.getTime();

        return dateFormat.format(date);

    }

    public static String plusOneYear(String dateString) throws ParseException {
        Date date = dateFormat.parse(dateString);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, 1);
        date = calendar.getTime();
        return dateFormat.format(date);
    }

    public static String formatStdDatetime(Date date) {
        return dateFormat.format(date);
    }
}
